package com.yzy.fly.boot.tableSharding;

import java.util.ArrayList;
import java.time.LocalDate;

public class ShardUtil {

    public static void main(String[] args) {
        LocalDate currentDate = LocalDate.now();
        int quarter = getQuarter(currentDate);

        System.out.println(quarter);
    }

    public static String getOddEvenYear(LocalDate date) {
        return getOddEvenYear(date.getYear());
    }

    public static String getOddEvenYear(int year) {
        if (year % 2 == 0) {
            return "b";
        } else {
            return "a";
        }
    }

    public static int getQuarter(LocalDate date) {
        int month = date.getMonthValue();

        if (month >= 1 && month <= 3) {
            return 1;
        } else if (month >= 4 && month <= 6) {
            return 2;
        } else if (month >= 7 && month <= 9) {
            return 3;
        } else if (month >= 10 && month <= 12) {
            return 4;
        }

        throw new IllegalArgumentException("Invalid month: " + month);
    }

}
